package com.zjitc.config;

import com.zjitc.mapper.UserMapper;
import java.io.IOException;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/12 13:46
 * @description:
 */
@Configuration
@Import(Datasource.class)
public class MybatisXmlConfig {
public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource datasource) throws IOException {
  SqlSessionFactoryBean sqlSessionFactoryBean=new SqlSessionFactoryBean();
  sqlSessionFactoryBean.setDataSource(datasource);
  PathMatchingResourcePatternResolver resolver=new PathMatchingResourcePatternResolver();
  sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:com/zjitc/mapper/*Mapper.xml"));
  return sqlSessionFactoryBean;
}
}
